package com.itheima.controller;

import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.ISetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
@RequestMapping("/setmeal")
public class SetmealController {

    @Autowired
    private ISetmealService setmealService;

    @PostMapping("/add")
    public Result add(@RequestParam("checkgroupIds") String checkgroupIds,@RequestBody Setmeal setmeal) {
        return setmealService.add(checkgroupIds,setmeal);
    }

    @PostMapping("/edit")
    public Result edit(@RequestParam("checkGroupIds") String checkGroupIds,@RequestBody Setmeal setmeal){
        return setmealService.edit(checkGroupIds,setmeal);
    }

    @GetMapping("/findById")
    public Result findById(@RequestParam("id") String id){
        return setmealService.findById(id);
    }

    @PostMapping("/findPage")
    public PageResult<Setmeal> findPage(@RequestBody QueryPageBean query){
        return setmealService.findPage(query);
    }

    @PostMapping("/upload")
    public Result upload(@RequestBody MultipartFile imgFile){
        return setmealService.upload(imgFile);
    }
}
